using System;
using GameFramework.Sound;
using UnityEngine;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;
using ShowEntityFailureEventArgs = UnityGameFramework.Runtime.ShowEntityFailureEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Show Entity")]
    [UnitSurtitle("Failure")]
    public sealed class ShowEntityFailure : FrameworkEventUnit<ShowEntityFailureEventArgs>
    {
        protected override int EventId => ShowEntityFailureEventArgs.EventId;
        protected override string HookName => UGFHookNames.ShowEntityFailure;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput EntityId
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput EntityLogicType
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput EntityAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput EntityGroupName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ErrorMessage
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            EntityId = ValueOutput<int>(nameof(EntityId));
            EntityLogicType = ValueOutput<Type>(nameof(EntityLogicType));
            EntityAssetName = ValueOutput<string>(nameof(EntityAssetName));
            EntityGroupName = ValueOutput<string>(nameof(EntityGroupName));
            ErrorMessage = ValueOutput<string>(nameof(ErrorMessage));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, ShowEntityFailureEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(EntityId, args.EntityId);
            flow.SetValue(EntityLogicType, args.EntityLogicType);
            flow.SetValue(EntityAssetName, args.EntityAssetName);
            flow.SetValue(EntityGroupName, args.EntityGroupName);
            flow.SetValue(ErrorMessage, args.ErrorMessage);
            flow.SetValue(UserData, args.UserData);
        }
    }
}